# Jumpluff - Pokémon Go Discord Bot

Query spreadsheets of points of interest to provide easy [Google Maps](https://maps.google.com/) pinning of Pokémon Go gyms

## Dependencies
- [Node.js](https://nodejs.org/en/) with npm
  - [lumo: Fast, cross-platform, standalone ClojureScript environment](https://github.com/anmonteiro/lumo)
  - [Fuse.js - JavaScript fuzzy-search library](http://fusejs.io/)
  - [discord.js](https://discord.js.org/)
  - [csv - npm](https://www.npmjs.com/package/csv)
- [Leiningen](https://leiningen.org/) to install [andare: core.async for bootstrapped ClojureScript](https://github.com/mfikes/andare)

## Setup

### Install dependencies
```shell
make deps
```

### Register a bot with Discord
<https://discordapp.com/developers/applications/me>
Copy the token

### Invite the bot to your server by generating and visiting an oauth link
<https://discordapp.com/developers/applications/me>
Select the following scopes:
- bot

And the following permissions:
- Manage Messages - to clear reactions on responses

### Run an instance
```shell
make DISCORD_TOKEN=<PASTE_TOKEN_HERE> run
```

#### Other run-time variables
- `JUMPLUFF_DATA` Directory of datasets
- `JUMPLUFF_VAR` Directory for the config file
- `JUMPLUFF_INLINE_DELIMITER` Character to use for inline queries
- `JUMPLUFF_QUERY_PREFIX` Space delimited list of command prefixes to trigger a query

### Start talking to the instance

As a Discord server administrator, configure the bot with commands via mentions
`@jumpluff help admin`

### Register your datasets with the instance

`@jumpluff add-dataset`
Arguments:
1. Name used to refer to the dataset
2. Filename of a CSV file in `JUMPLUFF_DATA`
- Zero based indexes of CSV columns
  1. Name column
  2. LatLon column
  3. Location description column
  4. EX raid potential column
  4. Nickname column

### Assign a channel a default dataset to use in queries from there

`@jumpluff channel-dataset [dataset name]`

## Usage

A traditional bot command prefix from `JUMPLUFF_QUERY_PREFIX` or wrapped with double `JUMPLUFF_INLINE_DELIMITER` in a channel with a default dataset

Query language:
dataset name : name filter - description filter (-ex|+ex|+ex-t)

## Datasets

A comma-separated values file in `JUMPLUFF_DATA`
Containing a header line then the following columns in any order:
- Exact Gym Name
- Location Coordinates
As parsed by `(-?\d{1,2}\.\d*,-?\d{1,2}\.\d*)`
- Location Description
Cross streets, property address, location notes
As an intentional way to handle line breaks while maintaining compatibility with various CSV implementations, when loaded a full-width slash(／) is replaced with a line break.
- EX-Raid Eligible Status
EX for eligible gyms
EX-T for triggered ex raid gyms
- Nickname for the gym

### Pull from a Google Docs spreadsheet
Export to CSV <https://docs.google.com/spreadsheets/d/DOCID/export?format=csv>

<!-- As a future feature this exporting process may be possible with a fetch command -->
### Import/Export with org-mode
For local editing in Emacs, Org Mode has `org-table-export` and `org-table-import`

### Import from an old map service
Apply <https://www.spotamon.com/gymscript.js> as a userscript
Navigate to <https://www.pokemongomap.info/>
Use the new S2Grid button to export gyms to csv

## Legal
Pokémon And All Respective Names are Trademark & © of Nintendo 1996-2018
